package com.humanminoritygame.schedule;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;

import com.humanminoritygame.model.RoomRepo;
import com.humanminoritygame.model.SubscriptionRepo;
import com.humanminoritygame.model.UserRepo;
import com.humanminoritygame.model.UserRoundResultRepo;

public class RoundsCron{
  private RoomRepo roomRepo;
  private UserRoundResultRepo userRoundResultRepo;
  private SessionFactory sessionFactory;
  private UserRepo userRepo;
  private SubscriptionRepo subscriptionRepo;
  private MailSender mailSender;
  private SimpleMailMessage templateMessage;
 
  
  @Autowired
  public RoundsCron(MailSender mailSender, SimpleMailMessage templateMessage, SessionFactory sessionFactory, RoomRepo roomRepo, UserRoundResultRepo userRoundResultRepo, UserRepo userRepo, SubscriptionRepo subscriptionRepo){
    this.roomRepo = roomRepo;
    this.userRoundResultRepo = userRoundResultRepo;
    this.sessionFactory = sessionFactory;
    this.userRepo = userRepo;
    this.subscriptionRepo = subscriptionRepo;
    this.mailSender = mailSender;
    this.templateMessage = templateMessage;
  }
  
  public void init() {
    RoundsThread rt = new RoundsThread(mailSender, templateMessage, sessionFactory, roomRepo, userRoundResultRepo, userRepo, subscriptionRepo);
    Thread newThrd = new Thread(rt);
    newThrd.start();
  }
}